import Vue from "vue"
import VueRouter from "vue-router"

Vue.use(VueRouter);

const routes = [
    {
        path: '/',
        redirect: '/dash-board1',
        meta: {
            loginRequire: true
        }
    },
    {
        path: '/',
        name: 'Home',
        component: () => import('@/views/system/Home'),
        meta: {
            loginRequire: true
        },
        children: [
            {
                path: 'dash-board',
                name: 'DashBoard',
                component: () => import('@/views/system/DashBoard'),
                meta: {
                    title: '系统首页',
                    loginRequire: true
                }
            },
            {
                path: 'dash-board1',
                name: 'DashBoard1',
                component: () => import('@/views/system/DashBoard1'),
                meta: {
                    title: '用户首页',
                    loginRequire: true
                }
            },
            {
                path: 'user-list',
                name: 'UserList',
                component: () => import('@/views/user/UserList'),
                meta: {
                    title: '用户列表',
                    loginRequire: true
                }
            },
            {
                path: 'hall-list',
                name: 'HallList',
                component: () => import('@/views/hall/HallList'),
                meta: {
                    title: '体育场馆列表',
                    loginRequire: true
                }
            },
            {
                path: 'equipment-list',
                name: 'EquipmentList',
                component: () => import('@/views/equipment/EquipmentList'),
                meta: {
                    title: '体育器材列表',
                    loginRequire: true
                }
            },
            {
                path: 'rental-list',
                name: 'RentalList',
                component: () => import('@/views/rental/RentalList'),
                meta: {
                    title: '租借器材列表',
                    loginRequire: true
                }
            },
            {
                path: 'appointment-list',
                name: 'AppointmentList',
                component: () => import('@/views/appointment/AppointmentList'),
                meta: {
                    title: '预约场馆列表',
                    loginRequire: true
                }
            },
            {
                path: 'announce-list',
                name: 'AnnounceList',
                component: () => import('@/views/announce/AnnounceList'),
                meta: {
                    title: '公告列表',
                    loginRequire: true
                }
            },
            {
                path: 'statistics',
                name: 'statistics',
                component: () => import('@/views/statistics/Statistics'),
                meta: {
                    title: '统计',
                    loginRequire: true
                }
            }
        ]
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/Login')
    },
    {
        path: '/register',
        name: 'Register',
        component: () => import('@/views/Register')
    },
    {
        path: '/',
        redirect: '/login',
    }
];

const router = new VueRouter({
    mode: "history",
    base: process.env.BASE_URL,
    routes
});

// 导航栏中用到了路由 防止重复点同一个菜单给出错误提示
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
};


export default router;
